enum MODEL{
    //% block="加速度"
    normAccel,
    //% block="角度"
    normGyro
}

enum SELECT{
    //% block="X轴"
    XAxis,
    //% block="Y轴"
    YAxis,
    //% block="Z轴"
    ZAxis
}

//% color="#00BFFF" iconWidth=50 iconHeight=40
namespace mpu6050{
    //% block="刷新MPU6050数据" blockType="command"
    export function MPU6050INIT(parameter: any, block: any) {
        Generator.addInclude('MPU6050include1', '#include <MPU6050.h>');
        Generator.addInclude('MPU6050include2', '#include <Wire.h>');
        Generator.addObject(`mpu6050obj`, `MPU6050`, `mpu;`);
        Generator.addObject(`mpu6050obj1`, `Vector`, `normAccel;`);
        Generator.addObject(`mpu6050obj2`, `Vector`, `normGyro;`);
        Generator.addSetup(`mpu6050SETUP`, `mpu.begin(MPU6050_SCALE_2000DPS, MPU6050_RANGE_2G);`);
        Generator.addCode(`normAccel = mpu.readNormalizeAccel();\n\tnormGyro = mpu.readNormalizeGyro();`);
    }
    
    //% block="获取 [op][model]" blockType="reporter"
    //% op.shadow="dropdown" op.options="SELECT" op.defl="SELECT.X轴"
    //% model.shadow="dropdown" model.options="MODEL" model.defl="MODEL.加速度"
    export function MPU6050ACCEL(parameter: any, block: any) {
        let Op = parameter.op.code;
        let Model = parameter.model.code;
        Generator.addCode(`${Model}.${Op}`);

    }
    //% block="获取摄氏度" blockType="reporter"
    export function MPU6050Temp(parameter: any, block: any) {

        Generator.addCode(`mpu.readTemperature()`);

    }
}
